package in.muton.edushare.components.tasks.electives.api;

import in.muton.edushare.EduShareSession;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.model.IModel;

import com.edushare.common.dao.CurriculumDAO;
import com.edushare.common.vo.Curricula;
import com.edushare.common.vo.Users;

public class Electives {

	public Electives(IModel<Users> userModel, IModel<Curricula> currModel, int sem) {
		this.userModel = userModel;
		this.currModel = currModel;
		this.semesterNumber = sem;
		commonElectiveList = new CommonElectives(userModel, currModel,sem);
	}

	public Integer getNumCommonElectivePanels() {
		return commonElectiveList.getNumCommonElectives();
	}

	public Integer getCommonElectivePanelGroupId(int index) {
		return commonElectiveList.getCommonElectiveGroupIds().get(index).get(0);
	}
	
	public List<List<Integer>> getCommonElectiveGroupIds(){
		return commonElectiveList.getCommonElectiveGroupIds();
	}

	public List<Integer> getUniquePanels() {
		List<Integer> uniqueGroupIds = new ArrayList<Integer>();
		CurriculumDAO cDAO = new CurriculumDAO(EduShareSession.get()
				.getSessionORMInterface());

		Integer electiveOptions = cDAO.getNumElectives(currModel.getObject(),
				semesterNumber);
		for(int i=0;i<electiveOptions;i++){
			if(!commonElectiveList.isCommonElective(i))
				uniqueGroupIds.add(i);
		}
		return uniqueGroupIds;
	}

	Integer semesterNumber = 0;
	IModel<Users> userModel = null;
	IModel<Curricula> currModel = null;
	public CommonElectives commonElectiveList = null;
}
